package com.ylsk.check.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylsk.check.domain.dto.RectificationReportDTO;
import com.ylsk.check.domain.so.RectificationReportSO;
import com.ylsk.check.domain.vo.RectificationReportVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.check.domain.RectificationReport;
import com.ylsk.check.service.IRectificationReportService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * 整改上报Controller
 *
 * @author yangsy
 * @date 2023-12-25
 */
@RestController
@RequestMapping("/check/rectificationReport")
public class RectificationReportController extends BaseController
{
    @Autowired
    private IRectificationReportService rectificationReportService;

    /**
     * 查询整改上报列表
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(RectificationReportSO rectificationReportSO)
    {
        startPage();
        List<RectificationReportVO> list = rectificationReportService.selectRectificationReportList(rectificationReportSO);
        return getDataTable(list);
    }

    /**
     * 导出整改上报列表
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReport:export')")
    @Log(title = "整改上报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RectificationReportSO rectificationReportSO)
    {
        List<RectificationReportVO> list = rectificationReportService.selectRectificationReportList(rectificationReportSO);
        ExcelUtil<RectificationReportVO> util = new ExcelUtil<RectificationReportVO>(RectificationReportVO.class);
        util.exportExcel(response, list, "整改上报数据");
    }

    /**
     * 获取整改上报详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReport:query')")
    @GetMapping(value = "/{rectificationReportId}")
    public AjaxResult getInfo(@PathVariable("rectificationReportId") Long rectificationReportId)
    {
        return success(rectificationReportService.selectRectificationReportByRectificationReportId(rectificationReportId));
    }

    /**
     * 新增整改上报
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReport:add')")
    @Log(title = "整改上报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RectificationReportDTO rectificationReportDTO)
    {
        return toAjax(rectificationReportService.insertRectificationReport(rectificationReportDTO));
    }

    /**
     * 修改整改上报
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReport:edit')")
    @Log(title = "整改上报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RectificationReportDTO rectificationReportDTO)
    {
        return toAjax(rectificationReportService.updateRectificationReport(rectificationReportDTO));
    }

    /**
     * 删除整改上报
     */
    @PreAuthorize("@ss.hasPermi('check:rectificationReport:remove')")
    @Log(title = "整改上报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rectificationReportIds}")
    public AjaxResult remove(@PathVariable Long[] rectificationReportIds)
    {
        return toAjax(rectificationReportService.deleteRectificationReportByRectificationReportIds(rectificationReportIds));
    }
}
